#include "../core/engine/world.h"
#include "cursor.h"

namespace sleek
{
    namespace gui
    {
        cursor::cursor(core::engine::interface *m) : mom(m)
        {
            isRender = false;
            showCursor(true);
        }
        cursor::~cursor()
        {
            mom->getDevice()->ShowMouse(true);
            disablePhysics();
        }
        void cursor::setPosition(core::math::vector2di a)
        {
            mom->getDevice()->WarpMouse(a);
            pos = a;
        }
        void cursor::setTexture(texture::texture *a)
        {
            tex = a;
        }
        void cursor::enablePhysics()
        {
            physique = true;
        }
        node::Node* cursor::drop()
        {
            node::Node *droped = 0;
            droped = pointed();
            return droped;
        }
        node::Node* cursor::pointed()
        {
            node::Node *tmp = 0;
            return tmp;
        }
        void cursor::grab()
        {
        }
        void cursor::disablePhysics()
        {
            grab();
        }
        void cursor::showCursor(bool a)
        {
            isVisible = a;
            mom->getDevice()->ShowMouse(a);
        }
        void cursor::showTexture(bool a)
        {
            isRender = a;
            mom->getDevice()->ShowMouse(!a);
        }
        bool cursor::manage(core::device::input *a)
        {
            if(pos == a->mouse_pos) return false;
            pos = a->mouse_pos;
            return true;
        }
        bool cursor::cursorIsShow()
        {
            return isVisible;
        }
        bool cursor::textureIsShow()
        {
            return isRender;
        }
        core::math::vector2di cursor::getPosition()
        {
            return pos;
        }
        texture::texture* cursor::getTexture()
        {
            return tex;
        }
        void cursor::render()
        {
            mom->getDrawManager()->setActiveMaterial(&rnd);
            if(mom && isRender && tex) mom->getDrawManager()->drawTexture(tex,pos);
        }
    }
}
